package grame;

import java.awt.Color;
public class Schematic 
{
	private Color[][] map;
	private Coordinates center;
	private int row, col, type;
	public Schematic()
	{
		this((int)(Math.random()*13));
	}
	public Schematic(int type)
	{
		this.type=type;
		this.map=new Color[5][5];
		this.row=this.map.length;
		this.col=this.map[0].length;
		this.center=new Coordinates(this.row/2, this.col/2);
		for(int i=0; i<this.map.length; i++)
			for(int j=0; j<this.map.length; j++)
				this.map[i][j]=Color.WHITE;
		switch(this.type)
		{
		case 0:
			def(2, 0);
			def(2, 1);
			def(1, 2);
			def(2, 2);
			def(3, 2);
			def(2, 3);
			def(2, 4);
			break;
		case 1:
			def(0, 2);
			def(1, 2);
			def(2, 1);
			def(2, 2);
			def(2, 3);
			def(3, 2);
			def(4, 2);
			break;
		case 2:
			def(0, 0);
			def(1, 0);
			def(2, 0);
			def(0, 1);
			def(0, 2);
			break;
		case 3:
			def(0, 0);
			def(0, 1);
			def(0, 2);
			def(0, 3);
			def(1, 0);
			def(2, 0);
			def(3, 0);
			break;
		case 4:
			def(0, 0);
			def(1, 0);
			def(2, 0);
			def(4, 0);
			def(0, 2);
			def(2, 2);
			def(3, 2);
			def(4, 2);
			def(0, 4);
			def(1, 4);
			def(2, 4);
			def(4, 4);
			break;
		case 5:
			def(0, 0);
			def(0, 1);
			def(0, 2);
			def(0, 4);
			def(2, 0);
			def(2, 2);
			def(2, 3);
			def(2, 4);
			def(4, 0);
			def(4, 1);
			def(4, 2);
			def(4, 4);
			break;
		case 6:
			def(0, 0);
			def(1, 0);
			def(2, 0);
			def(3, 0);
			def(4, 0);
			def(2, 1);
			def(2, 2);
			def(2, 3);
			def(0, 4);
			def(1, 4);
			def(2, 4);
			def(3, 4);
			def(4, 4);
			break;
		case 7:
			def(0, 0);
			def(0, 1);
			def(0, 2);
			def(0, 3);
			def(0, 4);
			def(1, 2);
			def(2, 2);
			def(3, 2);
			def(4, 0);
			def(4, 1);
			def(4, 2);
			def(4, 3);
			def(4, 4);
			break;
		case 8:
			def(0, 0);
			def(1, 0);
			def(3, 0);
			def(4, 0);
			def(1, 1);
			def(2, 1);
			def(3, 1);
			def(1, 3);
			def(2, 3);
			def(3, 3);
			def(0, 4);
			def(1, 4);
			def(3, 4);
			def(4, 4);
			break;
		case 9:
			def(0, 0);
			def(0, 1);
			def(0, 3);
			def(0, 4);
			def(1, 1);
			def(1, 2);
			def(1, 3);
			def(3, 1);
			def(3, 2);
			def(3, 3);
			def(4, 0);
			def(4, 1);
			def(4, 3);
			def(4, 4);
			break;
		case 10:
			def(1, 0);
			def(4, 0);
			def(0, 1);
			def(1, 1);
			def(3, 1);
			def(1, 3);
			def(3, 3);
			def(4, 3);
			def(0, 4);
			def(3, 4);
			break;
		case 11:
			def(0, 0);
			def(3, 0);
			def(1, 1);
			def(3, 1);
			def(4, 1);
			def(0, 3);
			def(1, 3);
			def(3, 3);
			def(1, 4);
			def(4, 4);
			break;
		case 12:
			def(0, 0);
			def(1, 0);
			def(3, 0);
			def(4, 0);
			def(0, 1);
			def(4, 1);
			def(2, 2);
			def(0, 3);
			def(4, 3);
			def(0, 4);
			def(1, 4);
			def(3, 4);
			def(4, 4);
			break;
		case 13:
			def(0, 0);
			def(1, 0);
			trig(2, 0);
			def(3, 0);
			def(4, 0);
			def(0, 1);
			def(4, 1);
			trig(0, 2);
			def(0, 3);
			def(4, 3);
			def(0, 4);
			def(1, 4);
			trig(2, 4);
			def(3, 4);
			def(4, 4);
			trig(4, 2);
			break;
		case 14:
			def(1, 1);
			def(2, 1);
			def(3, 1);
			def(1, 2);
			def(3, 2);
			def(1, 3);
			def(2, 3);
			def(3, 3);
			break;
		case 15:
			for(int i=0; i<this.map.length; i++)
				for(int j=0; j<this.map.length; j++)
					def(i, j);
			break;
		}
	}
	void def(int row, int col)
	{
		this.map[row][col]=Color.BLACK;
	}
	void trig(int row, int col)
	{
		this.map[row][col]=Color.cyan;
	}
	Coordinates getCenter()
	{
		return this.center;
	}
	Color getColor(Coordinates c)
	{
		return this.map[c.getY()][c.getX()];
	}
	int getType()
	{
		return this.type;
	}
	public void show()
	{
		String type=""+this.type;
		Base b=new Base(5, 5, 30, "Schematic "+type);
		for(int i=0; i<5; i++)
			for(int j=0; j<5; j++)
				b.gridPanel.setColor(new Coordinates(j, i), this.map[i][j]);
		b.setVisible(true);
	}
}

